<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

       //箭头函数的this指向依赖于外层函数的this指向，箭头函数中的this指向不绑定当前调用者，与当前调用者没有关系，箭头函数中的this指向定义时所在函数的this指向


       function myfn(){

       // console.log(this,11);

          setTimeout(function(){
            console.log(this,222);
          },1000);

          setTimeout(()=>{
            console.log(this,333);
          },2000);

       }

      // myfn();  // window window

     // new myfn();  // window  {}


      var brand = '华为';
     //let brand = '华为';
      var obj = {
        brand:'联想',
        demo:function(){
            setTimeout(function(){
                console.log(this.brand,'a111');
            },1000)

            setTimeout(()=>{
                console.log(this.brand,'b222');
            },2000);
        }
      }

     // obj.demo();  //华为  联想


      var goods = '小米手机';
      var obj2 = {
        goods:'华为电脑',
        fn:()=>{
            console.log(this,'00');

            setTimeout(function(){
                console.log(this.goods,11);
            },1000);

            setTimeout(()=>{
                console.log(this.goods,22);
            },2000);
        }
      }

     // obj2.fn();  //小米手机  小米手机


     var mydemo = ()=>{
          setTimeout(()=>{
              console.log(this,'mydemo....');
          },1000);
     }

    // mydemo.call(new Object);


    function  mydemo2() {
        console.log(this,'yes ok');
        setTimeout(()=>{
           console.log(this,'mydemo2...');
        },1000);
    }

    mydemo2.call(new Object);   // {}

    </script>
</head>
<body>
    
</body>
</html>